Repetier-Firmware  1.0.0
gameduino2.h
Go to the documentation of this file.
1 /*
2 
3 Implementation of the gameduino2 parts. Since they require a complete new
4 handling of everything gui related, we moved it into a separate file.
5 
6 */
7 
8 #include "gd2_ext.h"
9 
10 // Initalize display
12 {
14  HAL::spiBegin();
16  GD.begin();
18 }
19 
20 #define CELL_32_SPEED 0
21 #define CELL_32_FLOW 1
22 #define CELL_32_FAN 2
23 #define CELL_32_EXTRUDER 11
24 #define CELL_32_BED 14
25 #define CELL_32_SDCARD 15
26 #define CELL_32_MENU 16
27 #define CELL_32_EMERGENCY 17
28 #define CELL_32_POWER_ON 18
29 #define CELL_32_POWER_OFF 19
30 #define CELL_32_LIGHT_ON 20
31 #define CELL_32_LIGHT_OFF 21
32 #define CELL_32_PAUSE 22
33 #define CELL_32_PRINT 23
34 #define CELL_32_HOME 24
35 #define CELL_32_MOVE 25
36 #define CELL_32_CHECK_OFF 26
37 #define CELL_32_CHECK_ON 27
38 #define CELL_32_TARGET_POS 28
39 #define CELL_32_CURRENT_POS 29
40 #define CELL_32_CLOSE 30
41 #define CELL_32_BIGBTN_SEL_A 31
42 #define CELL_32_BIGBTN_SEL_B 32
43 #define CELL_32_BIGBTN_A 33
44 #define CELL_32_BIGBTN_B 34
45 
46 #define TAG_NONE 0
47 #define TAG_EMERGENCY 1
48 #define TAG_POWER 2
49 #define TAG_LIGHT 3
50 #define TAG_FAN 4
51 #define TAG_FAN_SLIDER 5
52 #define TAG_BED 6
53 #define TAG_BED_SLIDER 7
54 #define TAG_EXT0 8
55 #define TAG_EXT0_SLIDER 9
56 #define TAG_EXT1 10
57 #define TAG_EXT1_SLIDER 11
58 #define TAG_SPEED_SLIDER 12
59 #define TAG_FLOW_SLIDER 13
60 #define TAG_MENU 14
61 
62 class GD2
63 {
64 public:
65  static uint8_t screens[4];
66  static uint8_t screenPos;
67  static void startScreen()
68  {
70  GD.ClearColorRGB(0x103000);
71  GD.Clear();
73  GD.cmd_textP(240, 30, 31, OPT_CENTER, versionString);
74  GD.cmd_textP(240, 130, 31, OPT_CENTER, PSTR(UI_PRINTER_NAME));
75  GD.swap();
77  LOAD_ASSETS();
79  }
80  static void refresh()
81  {
82  switch(screens[screenPos]) {
83  case 0:
84  default:
86  break;
87  }
88  GD.swap();
89  }
90  static void parse(FSTRINGPARAM(text)) {
91  uid.col = 0;
92  uid.parse(text,false);
93  }
94  static void renderMainScreen() {
95 // GD.ClearColorRGB(0xf0f0f0L);
96  GD.ClearColorRGB(0xffffffL);
97  GD.Clear();
98  // Grid
99  GD.ColorRGB(0xabadb3L);
100  GD.Begin(RECTS);
101  GD.Vertex2ii(0,251);GD.Vertex2ii(480,272);
102  GD.Begin(LINES);
103  GD.Vertex2ii(0,58);GD.Vertex2ii(419, 58);
104  GD.Vertex2ii(419,0);GD.Vertex2ii(419, 250);
105  GD.Vertex2ii(0,250);GD.Vertex2ii(479, 250);
106  GD.Vertex2ii(444,250);GD.Vertex2ii(444, 272);
107  GD.ColorRGB(0x3b5e67);
108  GD.Begin(BITMAPS);
109  GD.Tag(TAG_MENU);
113  int iy = 51;
114  GD.Tag(TAG_POWER);
116  iy += 40;
117  GD.Tag(TAG_LIGHT);
119  iy += 40;
120 
127 
128  GD.Vertex2ii( 46, 74, SLIDER_HANDLE, 0);
129  GD.Vertex2ii( 46, 104, SLIDER_HANDLE, 0);
130  GD.Vertex2ii( 46, 134, SLIDER_HANDLE, 0);
131  GD.Vertex2ii( 46, 164, SLIDER_HANDLE, 1);
132  GD.Vertex2ii( 46, 194, SLIDER_HANDLE, 1);
133  GD.Vertex2ii( 46, 224, SLIDER_HANDLE, 1);
134  // Text
135  GD.ColorRGB(0);
136  parse(PSTR(UI_TEXT_PAGE_BUFFER));
137  GD.cmd_text(9, 8, 26, 0, uid.printCols);
138  parse(PSTR(UI_TEXT_PRINT_FILAMENT ":%Uf m"));
139  GD.cmd_text(9, 24, 26, 0, uid.printCols);
140  parse(PSTR(UI_TEXT_PRINT_TIME ":%Ut"));
141  GD.cmd_text(9, 40, 26, 0, uid.printCols);
142  parse(PSTR("X:%x0 mm"));
143  GD.cmd_text(330, 8, 26, 0, uid.printCols);
144  parse(PSTR("Y:%x1 mm"));
145  GD.cmd_text(330, 24, 26, 0, uid.printCols);
146  parse(PSTR("Z:%x2 mm"));
147  GD.cmd_text(330, 40, 26, 0, uid.printCols);
148  GD.ColorRGB(0xffffffL);
149  parse(PSTR("%os"));
150  GD.cmd_text(9, 250, 27, 0, uid.printCols);
151  }
152  // Check toush screen for new actions
153  static void checkTouch()
154  {
155  GD.get_inputs();
156  switch(GD.inputs.tag) {
157  case 1: // Emergency
158  break;
159  }
160  }
161 };
162 uint8_t GD2screens[4] = {0,0,0,0};
163 uint8_t screenPos = 0;
164 
165 void uiInitKeys() {}
166 void uiCheckKeys(int &action) {}
167 inline void uiCheckSlowEncoder() {}
168 void uiCheckSlowKeys(int &action)
169 {
170  GD2::checkTouch();
171 }
void Clear(byte c, byte s, byte t)
Definition: gd2_ext.h:1217
struct GDClass::@0 inputs
#define RECTS
Definition: gd2_ext.h:299
Definition: gameduino2.h:62
#define TAG_MENU
Definition: gameduino2.h:60
UIDisplay uid
Definition: ui.cpp:144
char printCols[MAX_COLS+1]
Definition: ui.h:613
#define CELL_32_FLOW
Definition: gameduino2.h:21
void ClearColorRGB(byte red, byte green, byte blue)
Definition: gd2_ext.h:1209
#define LINES
Definition: gd2_ext.h:293
#define BITMAPS
Definition: gd2_ext.h:291
#define CELL_32_FAN
Definition: gameduino2.h:22
static uint8_t screenPos
Definition: gameduino2.h:66
void uiCheckSlowEncoder()
Definition: gameduino2.h:167
void initializeLCD()
Definition: gameduino2.h:11
void swap(void)
Definition: gd2_ext.h:814
static void refresh()
Definition: gameduino2.h:80
#define CELL_32_MENU
Definition: gameduino2.h:26
static void delayMilliseconds(unsigned int delayMs)
Definition: HAL.h:518
static void startScreen()
Definition: gameduino2.h:67
void parse(const char *txt, bool ram)
Definition: ui.cpp:1285
#define CELL_32_POWER_OFF
Definition: gameduino2.h:29
void get_inputs(void)
Definition: gd2_ext.h:1674
#define TAG_LIGHT
Definition: gameduino2.h:49
void cmd_textP(int16_t x, int16_t y, byte font, uint16_t options, PGM_P s)
Definition: gd2_ext.h:1584
GDClass GD
Definition: gd2_ext.h:808
void uiCheckSlowKeys(int &action)
Definition: gameduino2.h:168
void begin(uint8_t options=(GD_CALIBRATE|GD_TRIM|GD_STORAGE))
Definition: gd2_ext.h:842
void Vertex2ii(uint16_t x, uint16_t y, byte handle=0, byte cell=0)
Definition: gd2_ext.h:1330
uint8_t tag
Definition: gd2_ext.h:83
#define ICONS32_HANDLE
Definition: gd2_ext.h:2400
#define CELL_32_EXTRUDER
Definition: gameduino2.h:23
static void parse(FSTRINGPARAM(text))
Definition: gameduino2.h:90
void ColorRGB(byte red, byte green, byte blue)
Definition: gd2_ext.h:1242
static void checkTouch()
Definition: gameduino2.h:153
void uiCheckKeys(int &action)
Definition: gameduino2.h:166
#define LOAD_ASSETS()
Definition: gd2_ext.h:2399
uint8_t GD2screens[4]
Definition: gameduino2.h:162
#define SLIDER_HANDLE
Definition: gd2_ext.h:2404
void Tag(byte s)
Definition: gd2_ext.h:1320
static void renderMainScreen()
Definition: gameduino2.h:94
void cmd_text(int16_t x, int16_t y, byte font, uint16_t options, const char *s)
Definition: gd2_ext.h:1573
#define CELL_32_EMERGENCY
Definition: gameduino2.h:27
uint8_t col
Definition: ui.h:591
#define OPT_CENTER
Definition: gd2_ext.h:306
static void spiBegin()
Definition: HAL.h:618
void uiInitKeys()
Definition: gameduino2.h:165
#define CELL_32_SPEED
Definition: gameduino2.h:20
#define FSTRINGPARAM(var)
Definition: HAL.h:53
#define CELL_32_LIGHT_OFF
Definition: gameduino2.h:31
#define TAG_POWER
Definition: gameduino2.h:48
#define TAG_EMERGENCY
Definition: gameduino2.h:47
void Begin(byte prim)
Definition: gd2_ext.h:1128
static uint8_t screens[4]
Definition: gameduino2.h:65
#define UI_PRINTER_NAME
Definition: Configuration.h:1766